/* 预加载页面 */
window.onload=function(){
    //轮播图
    var imgs = document.querySelectorAll(".slide_box img");
    var btn = document.querySelectorAll(".slide_box li");//小圆点
    var num = 0;
    btn[num].style.backgroundColor = "skyblue";
    var timer = setInterval(roll, 2000);
    function roll() {
        num++;
        num >= imgs.length ? num = 0 : num = num;
        imgs.forEach((item, index) => {
        item.style.display = 'none'
        btn[index].style.background = 'papayawhip';
      })
        imgs[num].style.display = 'block' //显示相应图片
        btn[num].style.background = 'skyblue'
    }
   
    btn.forEach(function (item, index) {
        item.onmouseenter = function () {
          clearInterval(timer);
          num = index - 1;
          roll();
        }
      item.onmouseleave = function () {
          timer = setInterval(roll, 1000);
      }
    })

// 表格填充数据
    var data=[{
        time:"1107",
        username:"小明",
    },
    {
        time:"1108",
        username:"小红",
    },]

    var tbody=document.querySelector("tbody");
        for(var i=0;i<data.length;i++){
            var trs=document.createElement("tr");
            tbody.appendChild(trs);
            //单元格
            for(var j in data[i]){
                var tds=document.createElement("td");
                tds.innerHTML=data[i][j];
                trs.appendChild(tds);
            }
            var tds=document.createElement("td");
            tds.innerHTML="<button>正常</button>";
            trs.appendChild(tds);
        }
}
    